package cn.qihua.action;

import java.util.List;

import org.apache.struts2.json.annotations.JSON;

import cn.qihua.model.BaseOrder;
import cn.qihua.service.IOrderService;
import cn.qihua.util.IPageAble;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @author 米修
 * 
 */

public class ListOrderAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3843927267348625277L;
	public IPageAble page;
	public String message;
	public Integer total;
	private boolean success = false;
	private IOrderService baseOrderService;
	private List<BaseOrder> listBaseOrder;

	public String findAll() {
		listBaseOrder = baseOrderService
				.findAll(page.getStart(), page.getLimit());
		this.setTotal(baseOrderService.getTotal());
		this.setSuccess(true);
		return SUCCESS;
	}

	public String findByStaNew() {
		listBaseOrder = baseOrderService.findByStatus("新订单", page.getStart(),
				page.getLimit());
		this.setTotal(baseOrderService.getTotalByProperty("status", "新订单"));
		this.setSuccess(true);
		return SUCCESS;
	}

	public String search() {
		return SUCCESS;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public IPageAble getPage() {
		return page;
	}

	public void setPage(IPageAble page) {
		this.page = page;
	}

	@JSON(name = "root")
	public List<BaseOrder> getListBaseOrder() {
		return listBaseOrder;
	}

	public void setListBaseOrder(List<BaseOrder> listBaseOrder) {
		this.listBaseOrder = listBaseOrder;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public void setBaseOrderService(IOrderService baseOrderService) {
		this.baseOrderService = baseOrderService;
	}

}
